package com.users.controller;

import com.users.entities.TabUsers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@Slf4j
public class UsersController {

    public static final  String URL = "http://localhost:8001";


    @Resource
    private RestTemplate rest;

    @GetMapping(value = "users/tab_users_findall")
    public String tab_users_findall(){
        return rest.getForObject(URL+"/tab_users_findall",String.class,TabUsers.class);
    }

    @GetMapping(value = "users/tab_users_save")
    public String tab_users_save(TabUsers u){
        Map<String,Object> response = rest.postForObject(URL+"/tab_users_save",u, Map.class);
        return response.toString();
    }


}
